

// 页码相关
let page = {
  total: 1,
  startIndex: 0,
  stepNumber: 20,
  currentPage: 1
};

//页面状态相关
let status = {
  modalEditCompany:{
    isShow:false
  }
};

// 和网络交互相关的参数
let params = {
  //搜索条件
  name: "",
  companyInfo:{
    id:"",
    name:"",
    accessWay:200,
    apiUrl:"",
    className:"",
    method:100,
    enName:"",
    icon:""
  }
};

// 页面的数据源
let data = {
  companyList: []
};

let companyTable = function (self) {
  return  [
    {
      type: 'index',
      title: '#',
      key: 'index',
      fixed: 'left',
      align: 'center',
      width: 60
    },
    {
      title: '公司名称',
      key: 'name',
      align: 'center',
      width: 160
    },
    {
      title: '运送方式',
      key: 'method',
      align: 'center',
      width: 110,
      render: (h, params) => {
        return (<tag color={params.row.method===100?'green':'red'}>{params.row.method===100?'普通快递':'商业快递'}</tag>);
      }
    },
    {
      title: '访问方式',
      key: 'accessWay',
      align: 'center',
      width: 120,
      render: (h, params) => {
        return (<div>{params.row.accessWay===100?'Html页面':'Api接口'}</div>);
      }
    },
    {
      title: '实现类',
      key: 'className',
      align: 'center',
      minWidth: 280,
    },
    {
      title: '创建时间',
      width: 160,
      key: 'createtime',
      render: (h, params) => {
        return h('div', self.$tiyBJTime(params.row.createtime) );
      }
    },
    {
      title: '操作',
      align: 'center',
      width: 200,
      render: (h, params) => {
        return h('div', [h('Button', {
          props: {type: 'primary', size: 'small', icon: "md-create"},
          style: {
            marginRight: '10px',  marginTop: '6px', marginBottom: '3px'
          },
          on: {
            click: () => {
              self.showCompanyEditModal(params.row);
            }
          }
          }, '编辑'),
          h('Button', {
            props: {type: 'error', size: 'small', icon: "md-remove-circle"},
            style: {
              marginRight: '10px',  marginTop: '6px', marginBottom: '3px'
            },
            on: {
              click: () => {
                self.confirmDeleteCompany(params.row.id, params.row.name);
              }
            }
          }, '删除')
        ]);
      }
    }
  ];
};


export  default  {
  tPage: page,
  tStatus: status,
  tParams: params,
  tTable: companyTable,
  tData: data
};
